import {
	request
} from '@/utils/request.js'
export default {
	state: {
		collectionList: []
	},
	mutations: {
		setCollection(state,{key,data}) {
			state[key] = data
			uni.setStorageSync('collectionList', state[key]);
		}
	},
	actions: {
		getCollection(state) {
			request({
				url: 'product/collect',
				data: {
					type: 'goods'
				}
			}).then(res => {
				let collectList = res.data.data.data.map((item,index) => {
					item.goods.checked = false
					item.goods.topping = false
					return item
				})
				state.commit("setCollection",{key:'collectionList',data:collectList})
			})
		}
	}
}
